﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Configuracion.AppCode
{
    public static class extensions
    {
        public static TValue safeValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default(TValue))
        {
            try
            {
                if (dictionary.Keys.Contains(key))
                    return dictionary[key];
                else
                    return defaultValue;
            }
            catch
            {
                return default(TValue);
            }
        }
    }
}